package com.kgc.controller;

import com.kgc.common.Result;
import com.kgc.service.interf.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/apis/admin/Statistics")
public class StatisticsController {
    @Autowired
    private StatisticsService statisticsService;

    /**
     * 统计
     * @return
     */
    @RequestMapping("/getStatistics")
    public String getStatistics() {
        int userCount = statisticsService.getUserCount();
        int articleCount = statisticsService.getArticleCount();
        int commentCountForNoEnd = statisticsService.getActivityCountForNoEnd();
        int getCommentCountForEnd = statisticsService.getActivityCountForEnd();
        List<Integer> Statistics = new ArrayList<>();
        Statistics.add(userCount);
        Statistics.add(articleCount);
        Statistics.add(commentCountForNoEnd);
        Statistics.add(getCommentCountForEnd);
        return Result.success("200","获取统计成功",Statistics);
    }

//    @RequestMapping("/getUserCount")
//    public String getUserCount() {
//        int userCount = statisticsService.getUserCount();
//        return Result.success("200","获取用户数成功",userCount);
//    }
//
//    /**
//     * 获取文章数
//     * @return
//     */
//    @RequestMapping("/getArticleCount")
//    public String getArticleCount() {
//        int articleCount = statisticsService.getArticleCount();
//        return Result.success("200","获取文章数成功",articleCount);
//    }
//
//    /**
//     * 获取未结束活动数量
//     * @return
//     */
//    @RequestMapping("/getActivityCountForNoEnd")
//    public String getActivityCountForNoEnd() {
//        int commentCountForNoEnd = statisticsService.getActivityCountForNoEnd();
//        return Result.success("200","获取未结束活动成功",commentCountForNoEnd);
//    }
//
//    /**
//     * 获取已结束活动数量
//     * @return
//     */
//    @RequestMapping("/getActivityCountForEnd")
//    public String getCommentCountForEnd() {
//        int getCommentCountForEnd = statisticsService.getActivityCountForEnd();
//        return Result.success("200","获取已结束活动成功",getCommentCountForEnd);
//    }
}
